'use strict';

module.exports = app => {
  app.validator.addRule('mongo-id', (rule, value) => {
    if (!/^[a-zA-Z0-9]{24}$/.test(value)) {
      return '参数必须是MongoDB id';
    }
  });
  app.validator.addRule('w-date', (rule, value) => {
    const dateStr = new Date(value).toISOString();
    if (dateStr !== value) {
      return '参数必须是Date类型';
    }
  });
};
